<template>
	<view class="device-log">
		<navbar>{{ device.deviceName }}</navbar>
		<view class="cell-group">
			<u-cell-group :border="false">
				<u-cell icon="file-text" :title="$tt('home.eventLog')" :isLink="true" size="large"
					@click="handleEventLogClick"></u-cell>
				<u-cell icon="bookmark" :title="$tt('home.Instructionlog')" :isLink="true" size="large"
					@click="handleOrderLogClick"></u-cell>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	import navbar from '@/components/navBar/index.vue';

	export default {
		name: 'DeviceLog',
		components: {
			navbar
		},
		props: {
			device: {
				type: Object,
				default: null,
				required: true
			}
		},
		data() {
			return {
				deviceId: 0,
				deviceName: '',
				serialNumber: '',
				productId: '',
				thingsModel: {}, // 物模型
				deviceInfo: {} // 设备信息
			};
		},
		created() {
			// 获取设备状态(兼容H5和APP)
			if (this.device.serialNumber) {
				this.deviceInfo = this.device;
				this.deviceName = this.device.deviceName;
				this.deviceId = this.device.deviceId;
				this.serialNumber = this.device.serialNumber;
				this.productId = this.device.productId;
			}
		},
		methods: {
			handleEventLogClick() {
				uni.navigateTo({
					url: `/pagesB/home/device/log/event?serialNumber=${this.serialNumber}&deviceName=${this.deviceName}&productId=${this.productId}`
				});
			},
			handleOrderLogClick() {
				uni.navigateTo({
					url: `/pagesB/home/device/log/order?deviceId=${this.deviceId}&serialNumber=${this.serialNumber}&deviceName=${this.deviceName}`
				});
			}
		}
	};
</script>

<style lang="scss">
	.device-log {
		.cell-group {
			margin: 20rpx;
			background: #ffffff;
			border-radius: 20rpx;
		}
	}
</style>